package com.ws.ssmzongjie3.mapper;

import com.ws.ssmzongjie3.bean.Collections;
import com.ws.ssmzongjie3.bean.Route;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CollectionsMapper {
    //根据用户id和路线id删除收藏记录
    @Delete("DELETE FROM collection WHERE user_id = #{user_id} AND route_id = #{route_id}")
    int deleteCollection(Collections collection);
    List<Route> RouteWithCollectionCountMap(Route route);
    @Delete("DELETE FROM collection WHERE collection_id = #{collection_id}")
    int deleteCollectionById(Collections collection);
    @Insert("INSERT INTO collection(user_id,route_id) VALUES(#{user_id},#{route_id})")
    int insertCollection(Collections collection);
    int updateCollectionById(Collections collection);
    //根据路线id和用户id查询收藏记录
    @Select("SELECT * FROM collection WHERE user_id = #{user_id} AND route_id = #{route_id}")
    Collections getCollectionById(Collections collection);
    List<Collections> listCollectionByUserId(Collections collection);
    int countCollectionByRouteId(Integer route_id);

}
